<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <title>cygwin环境下载android源码  &middot; 二三</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">


<meta name="description" content="cygwin环境下载android源码" />

<meta name="keywords" content="android源码下载, AOSP, ">

<link rel="author" href="http://plus.google.com/+Myprofile">


<meta property="og:title" content="cygwin环境下载android源码  &middot; 二三 ">
<meta property="og:site_name" content="二三"/>
<meta property="og:url" content="https://idersan.github.io/2017/08/14/cygwin%E7%8E%AF%E5%A2%83%E4%B8%8B%E8%BD%BDandroid%E6%BA%90%E7%A0%81/" />
<meta property="og:locale" content="zh-CN">


<meta property="og:type" content="article" />
<meta property="og:description" content="cygwin环境下载android源码"/>
<meta property="og:article:published_time" content="2017-08-14T16:41:50&#43;08:00" />
<meta property="og:article:modified_time" content="2017-08-14T16:41:50&#43;08:00" />

  
    
<meta property="og:article:tag" content="android源码下载">
    
<meta property="og:article:tag" content="AOSP">
    
  

  
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@Myprofile" />
<meta name="twitter:creator" content="@Myprofile" />
<meta name="twitter:title" content="cygwin环境下载android源码" />
<meta name="twitter:description" content="cygwin环境下载android源码" />
<meta name="twitter:url" content="https://idersan.github.io/2017/08/14/cygwin%E7%8E%AF%E5%A2%83%E4%B8%8B%E8%BD%BDandroid%E6%BA%90%E7%A0%81/" />
<meta name="twitter:domain" content="https://idersan.github.io/">
  

<script type="application/ld+json">
  {
    "@context": "http://schema.org",
    "@type": "Article",
    "headline": "cygwin环境下载android源码",
    "author": {
      "@type": "Person",
      "name": "http://profiles.google.com/+Myprofile?rel=author"
    },
    "datePublished": "2017-08-14",
    "description": "cygwin环境下载android源码",
    "wordCount": 257
  }
</script>



<link rel="canonical" href="https://idersan.github.io/2017/08/14/cygwin%E7%8E%AF%E5%A2%83%E4%B8%8B%E8%BD%BDandroid%E6%BA%90%E7%A0%81/" />
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="https://idersan.github.io/touch-icon-144-precomposed.png">
<link rel="icon" href="https://idersan.github.io/favicon.png">
<meta name="generator" content="Hugo 0.21-DEV" />

  <!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.2/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->



    <link rel="stylesheet" href="https://idersan.github.io/css/bootswatch/paper/bootstrap.min.css">


<link rel="stylesheet" href="https://idersan.github.io/css/font-awesome.min.css">
<link rel="stylesheet" href="https://idersan.github.io/css/style.css">


  <link rel="stylesheet" href="https://idersan.github.io/css/highlight/dark.css">


</head>
<body class="map[name:paper]" data-ng-app="myapp" data-ng-controller="MyController" data-ng-mouseleave="MouseLeave($event)">
    <header id="main-header">
  <nav class="navbar navbar-default navbar-fixed-top">
    <div class="container">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        
          
          <a class="navbar-brand-img" href="https://idersan.github.io/">
            <img alt="二三" src="https://idersan.github.io/images/brandimg.jpg">
            
          </a>
        </div>
        <div id="navbar" class="collapse navbar-collapse">
          <ul class="nav navbar-nav navbar-right">
            
            
            <li class="">

              <a href="https://idersan.github.io/post/" >
                <i class='fa fa-list'></i>
                博客
              </a>
            </li>
            
            <li class="">

              <a href="https://idersan.github.io/categories/" >
                <i class='fa fa-folder-open'></i>
                分类
              </a>
            </li>
            
            <li class="">

              <a href="https://idersan.github.io/tags/" >
                <i class='fa fa-tags'></i>
                标签
              </a>
            </li>
            
            <li class="">

              <a href="https://idersan.github.io/page/about-me" >
                <i class='fa fa-info-circle'></i>
                关于我
              </a>
            </li>
            
          </ul>
        </div>
        
      </div>
    </nav>
  </header>


<div class="container">
  <div class="row">
    <div class="col-sm-9">
      <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
  <div class="text-center">

    <h1>cygwin环境下载android源码
</h1>

    <div class="metas">
<small>
  <i class="fa fa-calendar"></i>
  <time datetime="2017-08-14">14 Aug, 2017</time>
</small>


  <small>
    &middot; by author
  
  &middot; Read in about 2 min
  &middot; (257 words)
</small>


<div class="margin-10">
  <i class="fa fa-tags"></i>
  
  <a href="https://idersan.github.io/tags/android" class="label label-primary">android</a>
  
  <a href="https://idersan.github.io/tags/aosp" class="label label-primary">AOSP</a>
  


</div>
<br>
</div>

  </div>
</div>

      <div class="content">
  

<h1 id="cygwin-环境准备:d6dc232260feb2ea00aacf790fc50e4e">cygwin 环境准备</h1>

<p>打开<a href="http://www.cygwin.com/">http://www.cygwin.com/</a> 下载set-x86_64.exe。安装时选择国内镜像 <a href="http://mirrors.163.com。">http://mirrors.163.com。</a></p>

<p>cygwin 安装时选择所有开发者选项。其它需要用到的工具有curl，vim，git 也需要全部选中安装。</p>

<h3 id="curl-ssl证书验证:d6dc232260feb2ea00aacf790fc50e4e">curl ssl证书验证:</h3>

<p>请求一个https 的api服务，看是否正常返回json数据</p>

<pre><code class="language-bash">curl -i https://api.github.com/users/octocat/orgs
</code></pre>

<p>如果返回</p>

<pre><code>curl: (77) error setting certificate verify locations:
  CAfile: C:\ruby\cacert.pem
  CApath: none
</code></pre>

<p>则执行以下命令</p>

<pre><code>echo 'cacert=/etc/ssl/certs/ca-bundle.crt' &gt; ~/.curlrc
</code></pre>

<p>再次请求api后，无错误提示，会正确返回json数据</p>

<pre><code>HTTP/1.1 200 OK
Date: Tue, 15 Aug 2017 01:49:31 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 5
Server: GitHub.com
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 57
X-RateLimit-Reset: 1502764991
Cache-Control: public, max-age=60, s-maxage=60
Vary: Accept
ETag: &quot;98f0c1b396a4e5d54f4d5fe561d54b44&quot;
X-GitHub-Media-Type: github.v3; format=json
Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
Access-Control-Allow-Origin: *
Content-Security-Policy: default-src 'none'
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-XSS-Protection: 1; mode=block
X-Runtime-rack: 0.013540
Vary: Accept-Encoding
X-GitHub-Request-Id: C473:DA1A:1DE4A30:2E84DF1:59925328
[

]

</code></pre>

<h1 id="android-源码下载配置:d6dc232260feb2ea00aacf790fc50e4e">android 源码下载配置</h1>

<p>清华大学镜像安装教程 <a href="https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/">https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/</a></p>

<p>不翻墙下载Android内核源码
<a href="http://blog.csdn.net/sunao2002002/article/details/53057374">http://blog.csdn.net/sunao2002002/article/details/53057374</a></p>

<p>建立当前用户的bin目录
mkdir ~/bin</p>

<p>建立源码存放的目录 在e盘下的的android目录</p>

<pre><code class="language-bash">mkdir /cygdrive/e/android
cd /cygdrive/e/android
</code></pre>

<p>使用git clone下载 repo</p>

<pre><code class="language-bash">git clone https://aosp.tuna.tsinghua.edu.cn/android/git-repo.git/
</code></pre>

<p>把git中的repo下载执行文件拷贝到用户的 bin目录中</p>

<pre><code class="language-bash">cp git-repo/repo ~/bin/
chmod a+x ~/bin/repo
</code></pre>

<p>建立一个.repo目录，并且把git-repo重名为repo移动到该目录下</p>

<pre><code class="language-bash">mkdir .repo
mv -r git-repo .repo/repo
</code></pre>

<p>打开bash</p>

<pre><code class="language-bash">vim ~/.bashrc
</code></pre>

<p>在最后一行追加，repo 的镜像地址</p>

<pre><code class="language-bash">export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
export PATH=~/bin:$PATH
</code></pre>

<p>更新环境变量，使其立即生效</p>

<pre><code class="language-bash">source ~/.bashrc
</code></pre>

<p>初始化仓库,查看各个版本号</p>

<pre><code class="language-bash">repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
</code></pre>

<p>初始化指定同步版本号</p>

<pre><code class="language-bash">repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-7.1.2_r8
</code></pre>

<p>开始同步源码树</p>

<pre><code class="language-bash">repo sync
</code></pre>

<p>同步源码的时候会出现一个错误</p>

<pre><code>error: unable to create file tests/P_str_escape/str\\escape.rs: No such file or directory
Traceback (most recent call last):
  File &quot;/cygdrive/e/androidsrc/.repo/repo/main.py&quot;, line 531, in &lt;module&gt;
    _Main(sys.argv[1:])
  File &quot;/cygdrive/e/androidsrc/.repo/repo/main.py&quot;, line 507, in _Main
    result = repo._Run(argv) or 0
  File &quot;/cygdrive/e/androidsrc/.repo/repo/main.py&quot;, line 180, in _Run
    result = cmd.Execute(copts, cargs)
  File &quot;/cygdrive/e/androidsrc/.repo/repo/subcmds/sync.py&quot;, line 821, in Execute
    project.Sync_LocalHalf(syncbuf, force_sync=opt.force_sync)
  File &quot;/cygdrive/e/androidsrc/.repo/repo/project.py&quot;, line 1327, in Sync_LocalHalf
    self._InitWorkTree(force_sync=force_sync)
  File &quot;/cygdrive/e/androidsrc/.repo/repo/project.py&quot;, line 2486, in _InitWorkTree
    raise GitError(&quot;cannot initialize work tree&quot;)
error.GitError: cannot initialize work tree
</code></pre>

<p>解决方案：</p>

<pre><code>打开e:\androidsrc\frameworks\compile\slang\tests\P_str_escape 目录，创建str 目录，并在str 目录中创建 escape.rs文件（文件内容为空）。
</code></pre>

<p>再次执行</p>

<pre><code>repo --trace sync
</code></pre>

<p>自动动手编译Android源码及SDK
<a href="http://blog.csdn.net/dd864140130/article/details/51718187">http://blog.csdn.net/dd864140130/article/details/51718187</a>
搭建编译环境
<a href="https://source.android.com/source/initializing?hl=zh-cn">https://source.android.com/source/initializing?hl=zh-cn</a></p>

</div>


      <footer>
  <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
      
  
    <nav><ul class="pager">
    
        <li class="previous">
          <a href="https://idersan.github.io/2017/06/12/postgresql-json%E6%95%B0%E6%8D%AE%E5%AD%98%E5%82%A8%E5%92%8C%E6%9D%A1%E4%BB%B6%E6%9F%A5%E8%AF%A2/" title="PostGreSQL Json数据存储和条件查询">
            <span aria-hidden="true">&larr;</span>上一章
          </a>
        </li>
    

    
      <li class="next">
        <a href="https://idersan.github.io/2017/08/14/hugo%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" title="hugo常用命令">
            下一章 <span aria-hidden="true">&rarr;</span>
        </a>
      </li>
    
    </ul> </nav>
  


</div>

  <div class="col-xs-12 col-sm-12 col-md-9 col-lg-9">
  
<div id="cloud-tie-wrapper" class="cloud-tie-wrapper"></div>
<script>
  var cloudTieConfig = {
    url: document.location.href, 
    sourceId: "",
    productKey: "c4cd25e250584e1fa12608cb72836d5d",
    target: "cloud-tie-wrapper"
  };
</script>
<script src="https://img1.cache.netease.com/f2e/tie/yun/sdk/loader.js"></script>

</div>

</footer>

    </div>
    
      <div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
        <div>
  

    <div class="section">
      <header><div class="title"><b>最近更新</b></div></header>
      <div class="content">
        <ul>
        
          <li>
          <a href="https://idersan.github.io/2017/08/18/%E5%AE%89%E8%A3%85apt-cyg/">安装apt cyg</a>
          </li>
        
          <li>
          <a href="https://idersan.github.io/2017/08/18/go%E8%87%AA%E7%AD%BE%E5%90%8D%E8%AF%81%E4%B9%A6%E5%8F%8C%E5%90%91%E8%AE%A4%E8%AF%81/">GO自签名证书双向认证</a>
          </li>
        
          <li>
          <a href="https://idersan.github.io/2017/08/14/hugo%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/">hugo常用命令</a>
          </li>
        
          <li>
          <a href="https://idersan.github.io/2017/08/14/cygwin%E7%8E%AF%E5%A2%83%E4%B8%8B%E8%BD%BDandroid%E6%BA%90%E7%A0%81/">cygwin环境下载android源码</a>
          </li>
        
          <li>
          <a href="https://idersan.github.io/2017/06/12/postgresql-json%E6%95%B0%E6%8D%AE%E5%AD%98%E5%82%A8%E5%92%8C%E6%9D%A1%E4%BB%B6%E6%9F%A5%E8%AF%A2/">PostGreSQL Json数据存储和条件查询</a>
          </li>
        
          <li>
          <a href="https://idersan.github.io/2017/06/11/%E7%94%9F%E6%88%90%E8%87%AA%E7%AD%BE%E5%90%8Dssl%E8%AF%81%E4%B9%A6/">生成自签名SSL证书</a>
          </li>
        
          <li>
          <a href="https://idersan.github.io/2017/05/31/go%E5%85%A5%E9%97%A8_%E4%B8%80/">Go入门_一</a>
          </li>
        
          <li>
          <a href="https://idersan.github.io/2017/05/08/hexo%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/">hexo博客搭建</a>
          </li>
        
          <li>
          <a href="https://idersan.github.io/post/">Posts</a>
          </li>
        
        </ul>
      </div>
    </div>
    
    
      
      
      <div class="section taxonomies">
        <header><div class="title">
          
              <b>分类(4)</b></div>
          
          
          
          </header>
        <div class="content">
          <ul>
            <li><a href="https://idersan.github.io/categories/%E5%BC%80%E5%8F%91wiki">开发wiki</a></li><li><a href="https://idersan.github.io/categories/go">go</a></li><li><a href="https://idersan.github.io/categories/android">android</a></li><li><a href="https://idersan.github.io/categories/database">database</a></li>
          </ul>
        </div>
      </div>
      
    
      
      
      <div class="section taxonomies">
        <header><div class="title">
          
          
              <b>标签(12)</b></div>          
          
          
          </header>
        <div class="content">
          <ul>
            <li><a href="https://idersan.github.io/tags/android">android</a></li><li><a href="https://idersan.github.io/tags/aosp">aosp</a></li><li><a href="https://idersan.github.io/tags/cygwin">cygwin</a></li><li><a href="https://idersan.github.io/tags/go">go</a></li><li><a href="https://idersan.github.io/tags/gohttpsserver">gohttpsserver</a></li><li><a href="https://idersan.github.io/tags/hexo">hexo</a></li><li><a href="https://idersan.github.io/tags/https">https</a></li><li><a href="https://idersan.github.io/tags/hugo">hugo</a></li><li><a href="https://idersan.github.io/tags/postgresql-json">postgresql-json</a></li><li><a href="https://idersan.github.io/tags/sql">sql</a></li>
          </ul>
        </div>
      </div>
      
    
      
      
    

</div>

      </div>
    
  </div>
</div>
      
<footer class="footer hidden-print">
  <div class="container">
    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
           <div class="pull-left">
  <a class="toplink" href="javascript:" id="return-to-top">回到顶部</a>
</div>
<div class="pull-right">

</div>

        </div>
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center">
              
    
<div class="container footline">
    <small>
         <span id="busuanzi_container_site_pv">本站总访问量<span id="busuanzi_value_site_pv"></span>次</span>
          
  code with <i class='fa fa-heart'></i>


    </small>
</div>

    
<div class="container copyright">
    <small>
  &copy; 2017 Copyright 二三

  </small>
</div>



        </div>
    </div>
  </div>
</footer>

    

<script src="//s3.amazonaws.com/mailmunch/static/site.js" id="mailmunch-script" data-mailmunch-site-id="" async="async"></script>



<script src="//load.sumome.com/" data-sumo-site-id="" async="async"></script>

<script src="https://idersan.github.io/js/jquery.min.js"></script>
<script src="https://idersan.github.io/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"></script>
<script src="https://idersan.github.io/js/popover/angular-storage.min.js"></script>
<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>


<script type="text/javascript">
  (function() {
    
    
    if (window.location.hostname == "localhost")
      return;

    
    
    
  })();
  $('#return-to-top').click(function() {      
    $('body,html').animate({
        scrollTop : 0                       
    }, 500);
});
</script>


<script src="https://idersan.github.io/js/highlight.pack.js"></script>
<script src="https://idersan.github.io/js/site.js"></script>
<script>hljs.initHighlightingOnLoad();</script>


<script>
  var _gaq=[['_setAccount','UA-99037232-1'],['_trackPageview']];
  (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
  g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
  s.parentNode.insertBefore(g,s)}(document,'script'));
</script>

<script>
var ENABLE_POPOVER =  false ; 
var EXPIRE_COOKIE =  5 ; 
var SHOW_MODAL_TIMEOUT =  10000 ; 
var MOUSE_LEAVE =  false ; 
var MODAL_SIZE = ""; 
var POST_URL = "https://zapier.com/hooks/catch/1227563/"; 
var SIGNUP_HEADER = "Join Our Newsletter";
var HEADER_IMAGE = "http://placehold.it/1000x600";
var IMG_DESCRIPTION = "Placeholder image for this popover modal optin form";
var SIGNUP_TEXT = "Signup today for free and be the first to get notified on new updates.";
var INPUT_PLACEHOLDER = "Enter your email";
var SUBMIT_BUTTON = "Subscribe";
var SUCCESS_MESSAGE = "Thanks for your subscription!";
var ERROR_MESSAGE = "Submitting form failed!";
var OPTIN =  false ;
var COOKIE_NAME = "mycookie1";
</script>
<script src="https://idersan.github.io/js/popover/angular-modal-service.min.js"></script>
<script src="https://idersan.github.io/js/angular-ismobile.min.js"></script>
<script src="https://idersan.github.io/js/popover/popover.min.js"></script>

  </body>
</html>

